<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../../js/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="../../css/reset.css" />
		<link rel="stylesheet" type="text/css" href="footer.css" />
		<link rel="stylesheet" href="../../css/lystyle.css" />
		<link rel="stylesheet" href="../../css/backstage.css" />
		<style type="text/css">
			/*修改底部字体颜色*/
			
			.foot:nth-child(2) {
				color: #e83023;
			}
			
			#showPic1 {
				width: 100%;
				height: 100%;
			}
			
			.imgG {
				display: none;
			}
			
			div.webuploader-pick {
				background-color: #00b7ee;
				width: 78px;
				height: 32px;
				font-size: 0.277777rem;
				text-align: center;
				padding-top: 0.208333rem;
				padding-bottom: 0.208333rem;
			}
			
			div.webuploader-pick-hover {
				background-color: #00a2d4;
				width: 78px;
				height: 32px;
			}
			
			.img-border {
				float: right;
				height: 2.3rem;
				border: 1px solid #ccc;
				border-radius: 10px;
			}
			
			@media screen and (min-width: 530px) {
				.img-border {
					height: 2.5rem;
				}
			}
			
			@media screen and (min-width: 600px) {
				.img-border {
					height: 2.7rem;
				}
			}
			
			@media screen and (min-width: 600px) {
				.img-border {
					height: 3.1rem;
				}
			}
			
			@media screen and (min-width: 700px) {
				.img-border {
					height: 3.5rem;
				}
			}
			
			@media screen and (min-width: 800px) {
				.img-border {
					height: 4.2rem;
				}
			}
			
			@media screen and (min-width: 1000px) {
				.img-border {
					height: 4.9rem;
				}
			}
			
			.blue-btn {
				padding: 0.1rem;
				height: 42%;
				width: 45%;
				text-align: center;
				position: absolute;
				top: 20%;
				left: 50%;
			}
			
			@media screen and (min-width: 600px) {
				.blue-btn {
					margin-left: 16.5%;
				}
			}
			
			@media screen and (min-width: 700px) {
				.blue-btn {
					margin-left: 19%;
				}
			}
			
			@media screen and (min-width: 1000px) {
				.blue-btn {
					margin-left: 20%;
				}
			}
		</style>
		<script src="../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>

		<script src="../qiniu/plupload-2.3.5/js/moxie.js" type="text/javascript"></script>
		<script src="../qiniu/plupload-2.3.5/js/plupload.dev.js" type="text/javascript"></script>
		<script src="../qiniu/dist/qiniu.js" type="text/javascript"></script>
		<script src="../qiniu/plupload-2.3.5/js/i18n/zh_CN.js" type="text/javascript"></script>
	</head>

	<body class="ly-bgcolor">
		<div id="wrap">
			<div id="main">
				<div id="header">
					<a id="headImg" href="javascript:history.go(-1)"><img class="headImg" src="../../images/12.png" /></a>
					<p id="headTitle">企业管理申请</p>
				</div>
				<div id="content" style=" font-size: 14px;">
					<div class="ly-form" style="padding: 0;">
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*企业名称</label>
								<div class="col-xs-8">
									<input class="form-control ly-input" id="firmName" placeholder="请输入企业名称" />
								</div>
							</div>
						</div>
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*所属行业</label>
								<div class="col-xs-8"><input id="firmTmt" class="form-control ly-input" placeholder="请输入所属行业" /></div>
							</div>
						</div>
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*员工人数</label>
								<div class="col-xs-8">
									<select id="firmNnt">
										<option value="10人以下">10人以下</option>
										<option value="10人-20人">10人-20人</option>
										<option value="20人-50人">20人-50人</option>
										<option value="50人-100人">50人-100人</option>
										<option value="100人-200人">100人-200人</option>
										<option value="200人-500人">200人-500人</option>
										<option value="500人-1000人">500人-1000人</option>
										<option value="100人以上">100人以上</option>
									</select>
								</div>
							</div>
							<div class="ly-form-item">
								<div class="row ly-item-content">
									<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*联系人姓名</label>
									<div class="col-xs-8">
										<input class="form-control ly-input" id="applyforName" placeholder="请输入联系人姓名" />
									</div>
								</div>
							</div>
							<div class="ly-form-item">
								<div class="row ly-item-content">
									<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*联系电话</label>
									<div class="col-xs-8">
										<input class="form-control ly-input" id="mobile" readOnly="true" placeholder="请输入手机号" />
									</div>
								</div>
							</div>
							<div class="ly-form-item">
								<div class="row ly-item-content">
									<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*注册地址</label>
									<div class="col-xs-8">
										<div class="row" id="city_4">
											<div class="col-xs-4">
												<select id="s_provinces" onchange="accessToAreas2(this.value)" class="ly_select prov padding-tb" value="">
													<option value="">省份</option>
												</select>
											</div>
											<div class="col-xs-4 padding-tb">
												<select id="s_citys" onchange="accessToAreas3(this.value)" class="ly_select city">
													<option value="">市</option>
												</select>
											</div>
											<div class="col-xs-4 padding-tb">
												<select id="s_countys" class="ly_select dist">
													<option value="">区</option>
												</select>
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="ly-form-item">
								<div class="row ly-item-content">
									<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*详细地址</label>
									<div class="col-xs-8"><input id="firmAddress" class="form-control ly-input" placeholder="请输入详细地址" /></div>
								</div>
							</div>
							<div style="width: 100%;height: 0.33rem;background: #ededed;"></div>
							<!--1-->
							<div class="ly-form-item">
								<div class="row ly-item-content">
									<div>
										<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*工商营业执照</label>
										<!--进度条-->
										<div id="fsUploadProgress1" class="col-xs-8">
											<span></span>
											<div style="padding-top: 0.2rem; text-align: center;"></div>
										</div>

									</div>
									<div class="col-xs-12" style="padding-bottom: 0.1rem;">
										<div class="col-xs-6"><img style="width: 90%; float: left;" src="../manager/images/shenfenz1.png"></div>
										<div class="col-xs-6 img-border" style="background: url(../manager/images/shanghcuanred1.png) no-repeat; background-size:100% 100%;">

											<!--图片-->
											<div class="divG" style="height: 100%;width: 100%;">
												<img style=" height: 100%;width: 100%;" src="" id="img1" class="imgG" />
											</div>
										</div>
									</div>

									<div class="col-xs-12" style="color: #999;line-height:0.38rem;text-align: center; margin-bottom: 0.1rem; font-size: 0.1rem;">*证件文字清晰易辨识 无反光无遮挡 垂直拍摄</div>
									<div class="col-xs-6 blue-btn" id="container1">
										<div id="pickfiles1" style="height:100%;width: 100%;"></div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="tijiao" style="width: 100%;height: 0.33rem;background: #ededed;"></div>
					<div class="tijiao" style="padding: 0.33rem;">
						<a id="submit" style="display: block;color: #fff;" class="ly-borderp">提交</a>
					</div>
				</div>
			</div>
			<!--图片资料-->
			<input type="hidden" value="" id="zl1" />
	</body>
	<script src="../../js/jquery-2.2.3.min.js"></script>
	<!--上传图片-->
	<script src="../../js/webuploader-0.1.5/webuploader.js"></script>
	<link src="../../js/webuploader-0.1.5/webuploader.css" rel="stylesheet">
	<style type="text/css">
		/**/
		
		#l-map {
			height: 300px;
			width: 100%;
		}
		
		#r-result {
			width: 100%;
		}
		/*图片上传*/
		
		.webuploader-container {
			position: relative;
		}
		
		.webuploader-element-invisible {
			position: absolute !important;
			clip: rect(1px, 1px, 1px, 1px);
			/* IE6, IE7 */
			clip: rect(1px, 1px, 1px, 1px);
		}
		
		.webuploader-pick {
			font-size: 14px;
			position: relative;
			display: inline-block;
			cursor: pointer;
			padding: 5px 12px 5px;
			background: #337ab7;
			color: #fff;
			text-align: center;
			border-radius: 3px;
			overflow: hidden;
		}
		
		.webuploader-pick-hover {
			background: #33A6E7;
		}
		
		.webuploader-pick-disable {
			opacity: 0.6;
			pointer-events: none;
		}
	</style>
	<script src="../../js/jquery.cookie.js"></script>
	<script src="../../../common/js/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	<script type="text/javascript">
		var tokenReztApp = $.cookie("tokenReztApp");
		console.log(tokenReztApp);
		if(!tokenReztApp) {
			window.location.href = "../login/login/login.html";
		}
		//用户信息
		var user, role, goodsId;
		//获取当前会员信息
		function currentyf() {
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109/member-service/auth/current?token=" + tokenReztApp,
				dataType: "JSON",
				async: false,
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					$.removeCookie('tokenReztApp', {
						expires: 7,
						path: '/'
					});
					$.removeCookie("tokenRh", {
						expires: 7,
						path: '/'
					});
					$.removeCookie('memberId', {
						expires: 7,
						path: '/'
					});
					$.removeCookie('roleId', {
						expires: 7,
						path: '/'
					});
					window.location.href = "../login/login/login.html";
				},
				success: function(data) {
					console.log(data.ext1);
					user = data.loginName;
					role = data.roleList[0].id; //角色
					goodsId = data.id;
					roles = data.roleList
						//判断会员

					for(var i = 0; i < roles.length; i++) {
						if(roles[i].id == 'f2') {
							$("#headTitle").html('创客续费');
							$("#tjhyf").hide();
						}
						if(roles[i].id == 'f1') {
							$("#membercost").html('200');
						}
					}

					//填写基本信息
					if(data.tel != null) {
						$("#mobile").val(data.tel);
					}
					if(data.tel != null) {
						$("#email").val(data.email);
					}
				}
			});
		}

		$(function() {
			currentyf();
			accessToAreas1(0);
		});
		//获取地区
		function accessToAreas1(id) {
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109//user-service/sys/regions?regionsParentId=" + id,
				dataType: "JSON",
				async: true,
				error: function(res) {
					console.log(res);
				},
				success: function(data) {
					for(var i = 0; i < data.length; i++) {
						$("#s_provinces").append("<option value='" + data[i].regionId + "'>" + data[i].localName + "</option>");
					}
				}
			});
		}

		function accessToAreas2(id) {
			if(!id){
				$("#s_citys").empty();
				$("#s_countys").empty();
				$("#s_citys").append("<option value=''>市</option>");
				$("#s_countys").append("<option value=''>区</option>");
				return;
			}
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109//user-service/sys/regions?regionsParentId=" + id,
				dataType: "JSON",
				async: true,
				error: function(res) {
					console.log(res);
				},
				success: function(data) {
					$("#s_citys").empty();
					$("#s_countys").empty();
					var tempid;
					for(var i = 0; i < data.length; i++) {
						if(i == 0) {
							tempid = data[i].regionId;
						}
						$("#s_citys").append("<option value='" + data[i].regionId + "'>" + data[i].localName + "</option>");
					}
					$("#s_citys option").change(accessToAreas3(tempid));
				}
			});
		}

		function accessToAreas3(id) {
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109//user-service/sys/regions?regionsParentId=" + id,
				dataType: "JSON",
				async: true,
				error: function(res) {
					console.log(res);
				},
				success: function(data) {
					$("#s_countys").empty();
					for(var i = 0; i < data.length; i++) {
						$("#s_countys").append("<option value='" + data[i].regionId + "'>" + data[i].localName + "</option>");
					}
				}
			});
		}
		//结束获取地区

		var uploader1 = Qiniu.uploader({
			runtimes: 'html5,flash,html4', // 上传模式，依次退化
			browse_button: 'pickfiles1', // 上传选择的点选按钮，必需			
			uptoken_func: function() { // 在需要获取uptoken时，该方法会被调用
				var res;
				$.ajax({
					cache: false,
					type: "GET",
					url: "http://47.104.13.109/attachment-service/getToken",
					dataType: "text",
					async: false,
					error: function(XMLHttpRequest, textStatus, errorThrown) {},
					success: function(data) {
						res = data;
					}
				});
				return res;
			},
			get_new_uptoken: false, // 设置上传文件的时候是否每次都重新获取新的uptoken
			unique_names: true, // 默认false，key为文件名。若开启该选项，JS-SDK会为每个文件自动生成key（文件名）			
			domain: 'wjx9701', // bucket域名，下载资源时用到，必需
			container: 'container1', // 上传区域DOM ID，默认是browser_button的父元素
			max_file_size: '8mb', // 最大文件体积限制
			max_retries: 1, // 上传失败最大重试次数
			dragdrop: false, // 开启可拖曳上传
			chunk_size: '4mb', // 分块上传时，每块的体积
			auto_start: true, // 选择文件后自动上传，若关闭需要自己绑定事件触发上传		
			init: {
				'FilesAdded': function(up, files) {
					plupload.each(files, function(file) {
						// 文件添加进队列后，处理相关的事情
					});
				},
				'BeforeUpload': function(up, file) {
					// 每个文件上传前，处理相关的事情
				},
				'UploadProgress': function(up, file) {
					// 每个文件上传时，处理相关的事情
					$("#fsUploadProgress1").css('display', 'block');
					var percent = file.percent;
					$("#fsUploadProgress1").find("span").css({
						"width": percent + "%"
					});
					$("#fsUploadProgress1").find("div").text("上传中 " + percent + "%");
					if(percent == "100") {
						$("#fsUploadProgress1").css('display', 'none');
					}
				},
				'FileUploaded': function(up, file, info) {
					// 每个文件上传成功后，处理相关的事情
					// 其中info.response是文件上传成功后，服务端返回的json，形式如：
					var res = JSON.parse(info.response);
					$("#zl1").val(res.key);
					$("#img1").attr("src", "http://oxjfr3ifx.bkt.clouddn.com/" + res.key);
					$("#img1").show();
				},
				'Error': function(up, err, errTip) {
					//上传出错时，处理相关的事情
				},
				'UploadComplete': function() {
					//队列文件处理完毕后，处理相关的事情
				},
				'Key': function(up, file) {
					// 若想在前端对每个文件的key进行个性化处理，可以配置该函数
					// 该配置必须要在unique_names: false，save_key: false时才生效
					var key = "";
					return key
				}
			}
		});

		$(document).ready(function() {
			$("#submit").click(function() {
				var firmName = $("#firmName").val();
				var firmTmt = $("#firmTmt").val();
				var firmNnt = $("#firmNnt").val();
				var applyforName = $("#applyforName").val();
				var mobile = $("#mobile").val();
				var s_provinces = $("#s_provinces").val();
				var s_citys = $("#s_citys").val();
				var s_countys = $("#s_countys").val();
				var firmAddress = $("#firmAddress").val();

				if(firmName == "" || firmName == null) {
					return alert("请填写企业名称");
				}
				if(firmTmt == "" || firmTmt == null) {
					return alert("请填写所属行业");
				}
				if(firmNnt == "" || firmNnt == null) {
					return alert("请选择企业人数");
				}
				if(applyforName == "" || applyforName == null) {
					return alert("请填写联系人姓名");
				}
				if(s_provinces == "" || s_provinces == null) {
					return alert("请选择省份");
				}
				if(s_citys == "" || s_citys == null) {
					return alert("请选择市");
				}
				if(s_countys == "" || s_countys == null) {
					return alert("请选择区");
				}
				if(firmAddress == "" || firmAddress == null) {
					return alert("请填写详细地址");
				}
				//图片链接
				var zl1 = $("#zl1").val();
				//图片链接
				if(zl1 == "") {
					alert("请上传工商营业执照");
					return;
				}
				$.ajax({
					type: "PUT",
					url: "http://10.0.47.157:5555/companyapplyfor-service/renheManage/sub",
					async: false,
					data: {
						firmName: firmName,
						firmTmt: firmTmt,
						firmNnt: firmNnt,
						firmTel: mobile,
						firmProvince: s_provinces,
						firmCity: s_citys,
						firmCounty: s_countys,
						firmAddress: firmAddress,
						firmBusinesslicense: zl1,
						applyforName: applyforName,
						applyforAccount: user,
						applyforId: goodsId,
						applyforRole: role
					},
					error: function(data) {
						alert("网络异常请稍后重试");
					},
					success: function(data) {
						if(data.code == 1) {
							alert(data.message);
							window.location.href = "person_intentApply.html";
						} else {
							alert(data.message);
						}
					}
				});
			})

		})
	</script>

</html>